<template>
    <div class="login_container">
        <div class="login_box">
            <!-- 头像框 -->
            <div class="avatar">
                <img src="../assets/logo.png" alt="">
            </div> 
            <!-- 表单 -->
           <el-form  class="login_form" ref="loginFormRef" :model="loginForm" :rules="loginFormRules">
             <!-- 用户 -->
              <el-form-item prop="username">
                <el-input v-model="loginForm.username" prefix-icon="el-icon-s-custom"></el-input>    
              </el-form-item>
              <!-- 密码 -->
              <el-form-item prop="password">
                <el-input v-model="loginForm.password" prefix-icon="el-icon-unlock" show-password></el-input>    
              </el-form-item>
               <!-- 按钮 -->
             <el-form-item class="btns"> 
                 <el-button @click="login" type="info" round  >登录</el-button>
                 <el-button @click="resetLoginForm" type="plain" round >重置</el-button>
             </el-form-item>
           </el-form>  
        </div>
    </div>
</template>

<script>
export default {
    data (){
        return {
            //登录表单的数据对象
              loginForm:{
                username:"admin",
                password:"123456"
              },
              //表单验证规则对象
              loginFormRules: {
                  username:[
                    { required: true, message: '请输入用户名称', trigger: 'blur' },
                    { min: 5, max: 10, message: '长度在 5 到 10 个字符', trigger: 'blur' }
                  ],
                  password: [
                    { required: true, message: '请输入用户名称', trigger: 'blur' },
                    { min: 6, max: 10, message: '长度在 6 到 10 个字符', trigger: 'blur' }  
                  ]   
              }  
        }
    },
    methods:{
         resetLoginForm(){
             this.$refs.loginFormRef.resetFields()
         },
         login(){
              this.$refs.login.resetFields()
         }
    }
}
</script>


<style lang="less" scoped>
    .login_container {
        background-color: #2b3c4d;
        height: 100%;
    }
    .login_box {
        width: 450px;
        height: 300px;
        background-color: #fff;
        position: absolute;
        left: 50%;
        top: 50%;
        transform: translate(-50%, -50%);
        .avatar {
            width: 130px;
            height: 130px;
            padding: 10px;
            border: 1px solid blue;
            border-radius: 50%;
            background-color: #fff;
            position: absolute;
            left: 50%;
            transform: translate(-50%, -50%);
            box-shadow: 0 0 12px #dddccd;
            img {
                width: 100%;
                height: 100%;
                border-radius: 50%;
                background-color: #fff;
            }
        }
    }
    .login_form {
        position: absolute;
        padding: 0 20px;
        width: 100%;
        bottom: 0;
        box-sizing: border-box;
        .btns {
            display: flex;
            justify-content: flex-end;
        }
    }
</style>